package MathHomeWorkTest;
/*
求一个数的算数平方根
 */
public class MathTest27 {
    public static void main(String[] args) {
        int d = 10;
        System.out.println(mySqrt(d));
    }

    public static double mySqrt(int num){
        double low = 0;
        double high = num;
        double accury=1e-3;
        double middle=(low+high)/2;
        while (Math.abs(middle*middle-num) > accury){
            if(middle * middle>num){
                high = middle;
            }else {
                low = middle;
            }
            middle = (low+high) / 2;
        }
        return middle;
    }
}
